package com.project.imageinterference.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @Description 常用工具方法
 * @Author cwhao
 * @Date 2025/2/6 下午3:05
 */
public class MyUtil {

    // 获取文件扩展名
    public static String getFileExtension(String fileName) {
        int lastIndexOfDot = fileName.lastIndexOf(".");
        return lastIndexOfDot == -1 ? "" : fileName.substring(lastIndexOfDot + 1).toLowerCase();
    }

    // 获取当前时间戳
    public static String getTimestamp() {
        LocalDateTime now = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss");
        return now.format(formatter);
    }
}
